package com.my.re;

import cn.hutool.core.util.ReUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: marshal
 * @date: 2022-01-10 11:35 AM
 */
public class ReTest {
    public static void main(String[] args) {
        String stake = "K23+198";
        System.out.println(getStakeNum(stake));

        String regex = "(aaaa)+.*?(eeee)";
//        String hexStr = "aaaa12000230303731313534333136303630303038011ee2eeeeaaaa12000230303731313534333136303630303038011ee2eeeeaaaaaa000130303731313534333136303630303038473130324c323033313130373131310001e607071a05f700040b00b004000000000000000000000000000000000000000000000000000000000c00b004000000000000000000000000000000000000000000000000000000001f00b004000000000000000000000000000000000000000000000000000000002000b004000000000000000000000000000000000000000000000000000000002d37eeeeaaaa12000230303731313534333136303630303038011ee2eeeefefefefefe820004630171010000aaaa12000230303731313534333136303630303038011ee2eeee";
//        System.out.println(reUtilTest(regex, hexStr));
//
//        String hexStr2 = "aaaa12000230303731313534333136303630303038011ee2eeee";
//        System.out.println(reUtilTest(regex, hexStr2));
//        String hexStr3 = "fefefefefe82000166014e000000";
//        System.out.println(reUtilTest(regex, hexStr3));
//        String hexStr4 = "aaaaaa00013030373131353433313630363030303847";
//        System.out.println(reUtilTest(regex, hexStr4));
        String hexStr5 = "aaaa12000230303731313534333136303630303038011ee2eeeeaa12000230303731313534333136303630303038011ee2eeaaaa12000230303731313534333136303630303038011ee2eeee";
        System.out.println(reUtilTest(regex, hexStr5));

//        System.out.println(hexStr.matches(regex));
//        System.out.println(hexStr2.matches(regex));
//        System.out.println(hexStr3.matches(regex));
//        System.out.println(hexStr4.matches(regex));
    }

    private static Integer getStakeNum(String stake) {
        ArrayList<String> list = ReUtil.findAll("\\d", stake, 0, new ArrayList<>());
        return Integer.parseInt(String.join("",list));
    }

    private static List<String> reUtilTest(String regx, String str) {
        return ReUtil.findAllGroup0(regx, str);
    }
}
